/**
 * Created by user on 2018/11/30.
 */
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ROOT_PATH = process.cwd()

module.exports = (env, argv) => {
    return {
        entry: path.resolve(__dirname, 'src/index'),
        output: {
            filename: 'bundle.[hash].js',
            path: path.resolve(__dirname, 'dist')
        },
        module: {
            rules: [
                {
                    test: /\.js/,
                    exclude: /node_modules/,
                    use: {
                        loader: 'babel-loader',
                        options: {
                            presets: ['env', 'stage-0', 'react']
                        }
                    }
                }
            ]
        },
        plugins: [
            new HtmlWebpackPlugin({
                template: path.join(ROOT_PATH, '/src/index.html'),
                title: 'fuck',
                filename: 'index.html',
                inject: true
            })
        ],
        devServer: {
            hot: true,
            inline: true,
            contentBase: path.join(__dirname, "dist"),
            port: 7000
        }
    }
}